
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Mix · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="sigils.html" />
    
    
    <link rel="prev" href="modules.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        <li class="header">第一部分：基础</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="basics.html">
            
                <a href="basics.html">
            
                    
                    基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="collections.html">
            
                <a href="collections.html">
            
                    
                    集合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="enum.html">
            
                <a href="enum.html">
            
                    
                    Enum 模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="pattern-matching.html">
            
                <a href="pattern-matching.html">
            
                    
                    模式匹配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="control-structures.html">
            
                <a href="control-structures.html">
            
                    
                    控制语句
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="functions.html">
            
                <a href="functions.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="pipe-operator.html">
            
                <a href="pipe-operator.html">
            
                    
                    管道操作符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="modules.html">
            
                <a href="modules.html">
            
                    
                    模块(Module)
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.10" data-path="mix.html">
            
                <a href="mix.html">
            
                    
                    Mix
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="sigils.html">
            
                <a href="sigils.html">
            
                    
                    魔符(Sigil)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="documentation.html">
            
                <a href="documentation.html">
            
                    
                    文档模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="testing.html">
            
                <a href="testing.html">
            
                    
                    测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="comprehensions.html">
            
                <a href="comprehensions.html">
            
                    
                    推导
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="strings.html">
            
                <a href="strings.html">
            
                    
                    字符串
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="date-time.html">
            
                <a href="date-time.html">
            
                    
                    日期和时间
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="mix-tasks.html">
            
                <a href="mix-tasks.html">
            
                    
                    自定义Mix任务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="iex-helpers.html">
            
                <a href="iex-helpers.html">
            
                    
                    IEx辅助函数
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">第二部分：高级</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../advanced/erlang.html">
            
                <a href="../advanced/erlang.html">
            
                    
                    和Erlang互操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../advanced/error-handling.html">
            
                <a href="../advanced/error-handling.html">
            
                    
                    错误处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="../advanced/escripts.html">
            
                <a href="../advanced/escripts.html">
            
                    
                    可执行文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="../advanced/concurrency.html">
            
                <a href="../advanced/concurrency.html">
            
                    
                    并发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="../advanced/otp-concurrency.html">
            
                <a href="../advanced/otp-concurrency.html">
            
                    
                    OTP并发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="../advanced/otp-supervisors.html">
            
                <a href="../advanced/otp-supervisors.html">
            
                    
                    OTP Supervisors
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="../advanced/otp-distribution.html">
            
                <a href="../advanced/otp-distribution.html">
            
                    
                    OTP 分布式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="../advanced/metaprogramming.html">
            
                <a href="../advanced/metaprogramming.html">
            
                    
                    元编程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.9" data-path="../advanced/umbrella-projects.html">
            
                <a href="../advanced/umbrella-projects.html">
            
                    
                    Umbrella Projects
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10" data-path="../advanced/typespec.html">
            
                <a href="../advanced/typespec.html">
            
                    
                    Specifications and types
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.11" data-path="../advanced/behaviours.html">
            
                <a href="../advanced/behaviours.html">
            
                    
                    行为
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.12" data-path="../advanced/gen-stage.html">
            
                <a href="../advanced/gen-stage.html">
            
                    
                    GenStage
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.13" data-path="../advanced/protocols.html">
            
                <a href="../advanced/protocols.html">
            
                    
                    协议
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.14" data-path="../advanced/nerves.html">
            
                <a href="../advanced/nerves.html">
            
                    
                    Nerves
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">第三部分：ECTO</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../ecto/basics.html">
            
                <a href="../ecto/basics.html">
            
                    
                    Basics
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../ecto/changesets.html">
            
                <a href="../ecto/changesets.html">
            
                    
                    Changesets
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../ecto/associations.html">
            
                <a href="../ecto/associations.html">
            
                    
                    关联关系
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="../ecto/querying.html">
            
                <a href="../ecto/querying.html">
            
                    
                    查询
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">第四部分：专题</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../specifics/plug.html">
            
                <a href="../specifics/plug.html">
            
                    
                    Plug
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="../specifics/eex.html">
            
                <a href="../specifics/eex.html">
            
                    
                    嵌入的 Elixir(EEx)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="../specifics/ets.html">
            
                <a href="../specifics/ets.html">
            
                    
                    Erlang 项式存储(ETS)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="../specifics/mnesia.html">
            
                <a href="../specifics/mnesia.html">
            
                    
                    Mnesia 数据库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="../specifics/debugging.html">
            
                <a href="../specifics/debugging.html">
            
                    
                    调试
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">第五部分：程序库</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../libraries/guardian.html">
            
                <a href="../libraries/guardian.html">
            
                    
                    Guardian(基础)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../libraries/poolboy.html">
            
                <a href="../libraries/poolboy.html">
            
                    
                    Poolboy
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="../libraries/benchee.html">
            
                <a href="../libraries/benchee.html">
            
                    
                    Benchee
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="../libraries/bypass.html">
            
                <a href="../libraries/bypass.html">
            
                    
                    Bypass
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="../libraries/distillery.html">
            
                <a href="../libraries/distillery.html">
            
                    
                    Distillery(基础)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="../libraries/stream-data.html">
            
                <a href="../libraries/stream-data.html">
            
                    
                    StreamData
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >Mix</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <p>&#x5728;&#x66F4;&#x6DF1;&#x5165;&#x4E86;&#x89E3; Elixir &#x4E4B;&#x524D;&#xFF0C;&#x6211;&#x4EEC;&#x5FC5;&#x987B;&#x5148;&#x5B66;&#x4E60; mix&#x3002;&#x5982;&#x679C;&#x4F60;&#x719F;&#x6089; Ruby &#x7684;&#x8BDD;&#xFF0C;mix &#x5C31;&#x662F; Bundler&#xFF0C;RubyGems &#x548C; Rake &#x7684;&#x7ED3;&#x5408;&#x3002;mix &#x5BF9;&#x4E8E;&#x5F00;&#x53D1; Elixir &#x81F3;&#x5173;&#x91CD;&#x8981;&#xFF0C;&#x6211;&#x4EEC;&#x5728;&#x8FD9;&#x7BC7;&#x8BFE;&#x7A0B;&#x53EA;&#x4F1A;&#x4ECB;&#x7ECD;&#x5B83;&#x7684;&#x90E8;&#x5206;&#x7279;&#x6027;&#x3002;&#x8981;&#x67E5;&#x770B; Mix &#x5728;&#x5F53;&#x524D;&#x73AF;&#x5883;&#x4E2D;&#x63D0;&#x4F9B;&#x7684;&#x6240;&#x6709;&#x5185;&#x5BB9;&#xFF0C;&#x8BF7;&#x8FD0;&#x884C; <code>mix help</code>&#x3002;</p>
<p>&#x76F4;&#x5230;&#x73B0;&#x5728;&#xFF0C;&#x6211;&#x4EEC;&#x8FD8;&#x4E00;&#x76F4;&#x7528; <code>iex</code> &#x548C; Elixir &#x6253;&#x4EA4;&#x9053;&#xFF0C;&#x8FD9;&#x79CD;&#x65B9;&#x6CD5;&#x660E;&#x663E;&#x662F;&#x6709;&#x5C40;&#x9650;&#x7684;&#x3002;&#x5728;&#x7F16;&#x5199;&#x5927;&#x578B;&#x9879;&#x76EE;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x4E3A;&#x4E86;&#x65B9;&#x4FBF;&#x7BA1;&#x7406;&#xFF0C;&#x6211;&#x4EEC;&#x4F1A;&#x628A;&#x4EE3;&#x7801;&#x5206;&#x6210;&#x4E0D;&#x540C;&#x7684;&#x6587;&#x4EF6;&#xFF0C;mix &#x5C31;&#x662F;&#x4E3A;&#x4E86;&#x7BA1;&#x7406;&#x9879;&#x76EE;&#x800C;&#x751F;&#x7684;&#x3002;</p>
<h2 id="&#x65B0;&#x5EFA;&#x9879;&#x76EE;">&#x65B0;&#x5EFA;&#x9879;&#x76EE;</h2>
<p>&#x8981;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x9879;&#x76EE;&#xFF0C;&#x53EA;&#x8981;&#x8FD0;&#x884C; <code>mix new</code> &#x547D;&#x4EE4;&#x5C31;&#x884C;&#xFF0C;&#x975E;&#x5E38;&#x7B80;&#x5355;&#x3002;&#x8FD9;&#x4E2A;&#x547D;&#x4EE4;&#x80FD;&#x5E2E;&#x6211;&#x4EEC;&#x81EA;&#x52A8;&#x751F;&#x6210;&#x9879;&#x76EE;&#x7684;&#x76EE;&#x5F55;&#x548C;&#x4E00;&#x4E9B;&#x6807;&#x51C6;&#x7684;&#x6A21;&#x677F;&#x6587;&#x4EF6;&#x3002;&#x5F88;&#x5BB9;&#x6613;&#x7406;&#x89E3;&#x5427;&#xFF0C;&#x90A3;&#x6211;&#x4EEC;&#x5F00;&#x59CB;&#x521B;&#x5EFA;&#x9879;&#x76EE;&#xFF1A;</p>
<pre><code class="lang-bash">$ mix new example
</code></pre>
<p>&#x4ECE;&#x7EC8;&#x7AEF;&#x4E0A;&#x7684;&#x8F93;&#x51FA;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x770B;&#x5230; mix &#x5DF2;&#x7ECF;&#x5E2E;&#x6211;&#x4EEC;&#x521B;&#x5EFA;&#x4E86;&#x76EE;&#x5F55;&#x548C;&#x6A21;&#x677F;&#x6587;&#x4EF6;&#xFF1A;</p>
<pre><code class="lang-bash">* creating README.md
* creating .gitignore
* creating .formatter.exs
* creating mix.exs
* creating config
* creating config/config.exs
* creating lib
* creating lib/example.ex
* creating <span class="hljs-built_in">test</span>
* creating <span class="hljs-built_in">test</span>/<span class="hljs-built_in">test</span>_helper.exs
* creating <span class="hljs-built_in">test</span>/example_test.exs
</code></pre>
<p>&#x8FD9;&#x7BC7;&#x8BFE;&#x7A0B;&#x6211;&#x4EEC;&#x53EA;&#x5173;&#x5FC3; <code>mix.exs</code> &#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#xFF0C;&#x56E0;&#x4E3A;&#x6211;&#x4EEC;&#x4F1A;&#x7528;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#x914D;&#x7F6E;&#x5E94;&#x7528;&#x3001;&#x4F9D;&#x8D56;&#x3001;&#x73AF;&#x5883;&#x4FE1;&#x606F;&#x8FD8;&#x6709;&#x7248;&#x672C;&#x3002;&#x7528;&#x4F60;&#x6700;&#x559C;&#x6B22;&#x7684;&#x7F16;&#x8F91;&#x5668;&#x6253;&#x5F00;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#xFF0C;&#x4F60;&#x4F1A;&#x770B;&#x5230;&#x7C7B;&#x4F3C;&#x4E0B;&#x9762;&#x7684;&#x5185;&#x5BB9;&#xFF08;&#x7B80;&#x6D01;&#x8D77;&#x89C1;&#xFF0C;&#x6CE8;&#x91CA;&#x5DF2;&#x7ECF;&#x5220;&#x9664;&#xFF09;&#xFF1A;</p>
<pre><code class="lang-elixir"><span class="hljs-class"><span class="hljs-keyword">defmodule</span> <span class="hljs-title">Example</span></span>.Mixfile <span class="hljs-keyword">do</span>
  <span class="hljs-keyword">use</span> Mix.Project

  <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">project</span></span> <span class="hljs-keyword">do</span>
    [
      <span class="hljs-symbol">app:</span> <span class="hljs-symbol">:example</span>,
      <span class="hljs-symbol">version:</span> <span class="hljs-string">&quot;0.1.0&quot;</span>,
      <span class="hljs-symbol">elixir:</span> <span class="hljs-string">&quot;~&gt; 1.5&quot;</span>,
      <span class="hljs-symbol">start_permanent:</span> Mix.env() == <span class="hljs-symbol">:prod</span>,
      <span class="hljs-symbol">deps:</span> deps()
    ]
  <span class="hljs-keyword">end</span>

  <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">application</span></span> <span class="hljs-keyword">do</span>
    [
      <span class="hljs-symbol">extra_applications:</span> [<span class="hljs-symbol">:logger</span>]
    ]
  <span class="hljs-keyword">end</span>

  <span class="hljs-function"><span class="hljs-keyword">defp</span> <span class="hljs-title">deps</span></span> <span class="hljs-keyword">do</span>
    []
  <span class="hljs-keyword">end</span>
<span class="hljs-keyword">end</span>
</code></pre>
<p>&#x6211;&#x4EEC;&#x5148;&#x6765;&#x770B; <code>project</code> &#x8FD9;&#x90E8;&#x5206;&#x7684;&#x5185;&#x5BB9;&#xFF0C;&#x6211;&#x4EEC;&#x5728; <code>app</code> &#x53D8;&#x91CF;&#x5B9A;&#x4E49;&#x4E86;&#x5E94;&#x7528;&#x540D;&#x79F0;&#xFF0C;<code>version</code> &#x5B9A;&#x4E49;&#x7248;&#x672C;&#x53F7;&#xFF0C;<code>elixir</code> &#x5B9A;&#x4E49; Elixir &#x7684;&#x7248;&#x672C;&#x53F7;&#xFF0C;&#x4EE5;&#x53CA; <code>deps</code> &#x5B9A;&#x4E49;&#x6211;&#x4EEC;&#x7684;&#x4F9D;&#x8D56;&#x3002;</p>
<p>&#x4E0B;&#x9762;&#x8FD8;&#x4F1A;&#x8BB2;&#x5230;&#xFF0C;<code>application</code> &#x90E8;&#x5206;&#x7684;&#x5185;&#x5BB9;&#x5728;&#x751F;&#x4EA7;&#x5E94;&#x7528;&#x6587;&#x4EF6;&#x7684;&#x65F6;&#x5019;&#x4F1A;&#x7528;&#x5230;&#x3002;</p>
<h2 id="&#x4EA4;&#x4E92;">&#x4EA4;&#x4E92;</h2>
<p>&#x6709;&#x65F6;&#x5019;&#x9700;&#x8981;&#x7528; <code>iex</code> &#x548C;&#x6211;&#x4EEC;&#x7684;&#x9879;&#x76EE;&#x4EA4;&#x4E92;&#xFF0C;&#x5E78;&#x8FD0;&#x7684;&#x662F;&#xFF0C;mix &#x652F;&#x6301;&#x8FD9;&#x4E2A;&#x529F;&#x80FD;&#x3002;&#x7F16;&#x8BD1;&#x4E86;&#x9879;&#x76EE;&#x4E4B;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x7528;&#x4E0B;&#x9762;&#x7684;&#x547D;&#x4EE4;&#x6253;&#x5F00;&#x4E00;&#x4E2A;&#x65B0;&#x7684; <code>iex</code> &#x4F1A;&#x8BDD;&#xFF1A;</p>
<pre><code class="lang-bash">$ <span class="hljs-built_in">cd</span> example
$ iex -S mix
</code></pre>
<p>&#x8FD9;&#x6837; <code>iex</code> &#x542F;&#x52A8;&#x7684;&#x65F6;&#x5019;&#x4F1A;&#x628A;&#x4F60;&#x7684;&#x5E94;&#x7528;&#x548C;&#x4F9D;&#x8D56;&#x90FD;&#x52A0;&#x8F7D;&#x5230;&#x5F53;&#x524D;&#x73AF;&#x5883;&#xFF08;&#x8FD9;&#x6837;&#x4F60;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x5728; <code>iex</code> &#x4E2D;&#x5BFC;&#x5165;&#x548C;&#x8FD0;&#x884C;&#x7F16;&#x8BD1;&#x597D;&#x7684;&#x4EE3;&#x7801;&#xFF09;&#x3002;</p>
<h2 id="&#x7F16;&#x8BD1;">&#x7F16;&#x8BD1;</h2>
<p>Mix &#x5F88;&#x667A;&#x80FD;&#xFF0C;&#x80FD;&#x591F;&#x5728;&#x9700;&#x8981;&#x7684;&#x65F6;&#x5019;&#x81EA;&#x52A8;&#x7F16;&#x8BD1;&#x4F60;&#x7684;&#x6539;&#x52A8;&#xFF0C;&#x4E0D;&#x8FC7;&#x6709;&#x65F6;&#x5019;&#x8FD8;&#x662F;&#x8981;&#x624B;&#x52A8;&#x7F16;&#x8BD1;&#x9879;&#x76EE;&#x3002;&#x8FD9;&#x4E2A;&#x90E8;&#x5206;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x8BB2;&#x8BB2;&#x5982;&#x4F55;&#x7F16;&#x8BD1;&#x9879;&#x76EE;&#xFF0C;&#x4EE5;&#x53CA;&#x7F16;&#x8BD1;&#x7684;&#x65F6;&#x5019;&#x90FD;&#x505A;&#x4E86;&#x4EC0;&#x4E48;&#x3002;</p>
<p>&#x53EA;&#x8981;&#x5728;&#x9879;&#x76EE;&#x7684;&#x6839;&#x76EE;&#x5F55;&#x8FD0;&#x884C; <code>mix compile</code> &#x547D;&#x4EE4;&#xFF0C;&#x5C31;&#x80FD;&#x7F16;&#x8BD1;&#x6211;&#x4EEC;&#x7684;&#x9879;&#x76EE;&#xFF1A;<br><strong>&#x6CE8;&#x610F;&#xFF1A;&#x9879;&#x76EE;&#x7684;&#x6DF7;&#x5408;&#x4EFB;&#x52A1;&#x53EA;&#x80FD;&#x4ECE;&#x9879;&#x76EE;&#x6839;&#x76EE;&#x5F55;&#x4E2D;&#x83B7;&#x5F97;&#xFF0C;&#x5426;&#x5219;&#x53EA;&#x6709;&#x5168;&#x5C40;&#x7684; Mix &#x4EFB;&#x52A1;&#x53EF;&#x7528;</strong></p>
<pre><code class="lang-bash">$ mix compile
</code></pre>
<p>&#x56E0;&#x4E3A;&#x6211;&#x4EEC;&#x7684;&#x9879;&#x76EE;&#x6CA1;&#x6709;&#x591A;&#x5C11;&#x5185;&#x5BB9;&#xFF0C;&#x5C3D;&#x7BA1;&#x7F16;&#x8BD1;&#x6210;&#x529F;&#xFF0C;&#x4F46;&#x662F;&#x5E76;&#x6CA1;&#x6709;&#x5F88;&#x591A;&#x5185;&#x5BB9;&#x8F93;&#x51FA;&#xFF1A;</p>
<pre><code class="lang-bash">Compiled lib/example.ex
Generated example app
</code></pre>
<p>&#x5F53;&#x6211;&#x4EEC;&#x7F16;&#x8BD1;&#x9879;&#x76EE;&#x65F6;&#xFF0C;mix &#x4F1A;&#x81EA;&#x52A8;&#x521B;&#x5EFA;&#x4E00;&#x4E2A; <code>_build</code> &#x76EE;&#x5F55;&#xFF0C;&#x67E5;&#x770B; <code>_build</code> &#x76EE;&#x5F55;&#xFF0C;&#x4F60;&#x4F1A;&#x770B;&#x5230;&#x5DF2;&#x7ECF;&#x7F16;&#x8BD1;&#x597D;&#x7684;&#x6587;&#x4EF6;&#xFF1A; <code>example.app</code>&#x3002;</p>
<h2 id="&#x7BA1;&#x7406;&#x4F9D;&#x8D56;">&#x7BA1;&#x7406;&#x4F9D;&#x8D56;</h2>
<p>&#x6211;&#x4EEC;&#x7684;&#x9879;&#x76EE;&#x73B0;&#x5728;&#x8FD8;&#x6CA1;&#x6709;&#x4EFB;&#x4F55;&#x4F9D;&#x8D56;&#xFF0C;&#x4E0D;&#x8FC7;&#x5F88;&#x5FEB;&#x5C31;&#x4F1A;&#x6709;&#x4E86;&#x3002;&#x6240;&#x4EE5;&#x6211;&#x4EEC;&#x5C31;&#x63D0;&#x524D;&#x8BB2;&#x8BB2;&#x5982;&#x4F55;&#x5B9A;&#x4E49;&#x4F9D;&#x8D56;&#x4EE5;&#x53CA;&#x83B7;&#x53D6;&#x4F9D;&#x8D56;&#x3002;</p>
<p>&#x8981;&#x589E;&#x52A0;&#x65B0;&#x7684;&#x4F9D;&#x8D56;&#xFF0C;&#x6211;&#x4EEC;&#x9996;&#x5148;&#x8981;&#x628A;&#x5B83;&#x6DFB;&#x52A0;&#x5230; <code>mix.exs</code> &#x6587;&#x4EF6;&#x7684; <code>deps</code> &#x90E8;&#x5206;&#xFF0C;&#x6240;&#x6709;&#x7684;&#x4F9D;&#x8D56;&#x7EC4;&#x6210;&#x4E86;&#x4E00;&#x4E2A;&#x5217;&#x8868;&#xFF0C;&#x6BCF;&#x4E2A;&#x9879;&#x662F;&#x4E00;&#x4E2A;&#x4E8C;&#x5143;&#x5143;&#x7956;&#xFF1A;&#x7B2C;&#x4E00;&#x4E2A;&#x503C;&#x662F;&#x539F;&#x5B50;&#x8868;&#x793A;&#x7684;&#x5305;&#x540D;&#x79F0;&#xFF0C;&#x7B2C;&#x4E8C;&#x4E2A;&#x662F;&#x5305;&#x7684;&#x7248;&#x672C;&#x53F7;&#xFF0C;&#x7248;&#x672C;&#x53F7;&#x53EF;&#x4EE5;&#x7701;&#x7565;&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x627E;&#x4E86;&#x4E00;&#x4E2A;&#x6709;&#x4F9D;&#x8D56;&#x7684;&#x9879;&#x76EE; <a href="https://github.com/doomspork/phoenix_slim" target="_blank">phoenix_slim</a> &#x4F5C;&#x4E3A;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code class="lang-elixir"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">deps</span></span> <span class="hljs-keyword">do</span>
  [
    {<span class="hljs-symbol">:phoenix</span>, <span class="hljs-string">&quot;~&gt; 1.1 or ~&gt; 1.2&quot;</span>},
    {<span class="hljs-symbol">:phoenix_html</span>, <span class="hljs-string">&quot;~&gt; 2.3&quot;</span>},
    {<span class="hljs-symbol">:cowboy</span>, <span class="hljs-string">&quot;~&gt; 1.0&quot;</span>, <span class="hljs-symbol">only:</span> [<span class="hljs-symbol">:dev</span>, <span class="hljs-symbol">:test</span>]},
    {<span class="hljs-symbol">:slime</span>, <span class="hljs-string">&quot;~&gt; 0.14&quot;</span>}
  ]
<span class="hljs-keyword">end</span>
</code></pre>
<p>&#x4F60;&#x4E5F;&#x8BB8;&#x5DF2;&#x7ECF;&#x770B;&#x51FA;&#x6765;&#x4E86;&#xFF0C;<code>cowboy</code> &#x8FD9;&#x4E2A;&#x4F9D;&#x8D56;&#x53EA;&#x6709;&#x5728;&#x5F00;&#x53D1;&#x548C;&#x6D4B;&#x8BD5;&#x73AF;&#x5883;&#x624D;&#x9700;&#x8981;&#x3002;</p>
<p>&#x5B9A;&#x4E49;&#x597D;&#x4F9D;&#x8D56;&#xFF0C;&#x8FD8;&#x6709;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x6B65;&#x9AA4;&#xFF1A;&#x83B7;&#x53D6;&#x4F9D;&#x8D56;&#x3002;&#x8FD9;&#x548C; <code>bundle install</code> &#x7684;&#x6548;&#x679C;&#x4E00;&#x6837;&#xFF1A;</p>
<pre><code class="lang-bash">$ mix deps.get
</code></pre>
<p>&#x597D;&#x4E86;&#xFF01;&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x5B9A;&#x4E49;&#x5E76;&#x4E14;&#x83B7;&#x53D6;&#x4E86;&#x9879;&#x76EE;&#x7684;&#x4F9D;&#x8D56;&#x3002;&#x8FD9;&#x6837;&#x6709;&#x65B0;&#x4F9D;&#x8D56;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x77E5;&#x9053;&#x600E;&#x4E48;&#x53BB;&#x5904;&#x7406;&#x4E86;&#x3002;</p>
<h2 id="&#x73AF;&#x5883;&#x7BA1;&#x7406;">&#x73AF;&#x5883;&#x7BA1;&#x7406;</h2>
<p>&#x548C; Bundler &#x5F88;&#x76F8;&#x4F3C;&#xFF0C;mix &#x4E5F;&#x652F;&#x6301;&#x4E0D;&#x540C;&#x7684;&#x73AF;&#x5883;&#x3002;&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x5F00;&#x7BB1;&#x5373;&#x7528;&#x7684; mix &#x6709;&#x4E09;&#x79CD;&#x914D;&#x7F6E;&#x73AF;&#x5883;&#xFF1A;</p>
<ul>
<li><code>:dev</code> &#x2014; &#x9ED8;&#x8BA4;&#x7684;&#x73AF;&#x5883;</li>
<li><code>:test</code> &#x2014; &#x6D4B;&#x8BD5;&#x73AF;&#x5883;&#xFF0C;&#x4F7F;&#x7528; <code>mix test</code> &#x540E;&#x9762;&#x4F1A;&#x8BB2;&#x5230;</li>
<li><code>:prod</code> &#x2014; &#x751F;&#x4EA7;&#x73AF;&#x5883;&#xFF0C;&#x628A;&#x5E94;&#x7528;&#x4E0A;&#x7EBF;&#x5230;&#x751F;&#x4EA7;&#x73AF;&#x5883;&#x4E0B;&#x7684;&#x914D;&#x7F6E;&#x9879;</li>
</ul>
<p>&#x53EF;&#x4EE5;&#x4ECE; <code>Mix.env</code> &#x53D8;&#x91CF;&#x4E2D;&#x83B7;&#x53D6;&#x5F53;&#x524D;&#x7684;&#x73AF;&#x5883;&#xFF0C;&#x800C;&#x4E14;&#x73AF;&#x5883;&#x4E5F;&#x53EF;&#x4EE5;&#x901A;&#x8FC7; <code>MIX_ENV</code> &#x73AF;&#x5883;&#x53D8;&#x91CF;&#x6765;&#x914D;&#x7F6E;&#xFF1A;</p>
<pre><code class="lang-bash">$ MIX_ENV=prod mix compile
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="modules.html" class="navigation navigation-prev " aria-label="Previous page: 模块(Module)">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="sigils.html" class="navigation navigation-next " aria-label="Next page: 魔符(Sigil)">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"version":"1.1.0","title":"Mix","level":"1.10","depth":1,"next":{"title":"魔符(Sigil)","level":"1.11","depth":1,"path":"lessons/basics/sigils.md","ref":"lessons/basics/sigils.md","articles":[]},"previous":{"title":"模块(Module)","level":"1.9","depth":1,"path":"lessons/basics/modules.md","ref":"lessons/basics/modules.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"lessons/basics/mix.md","mtime":"2019-11-05T02:25:51.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-11-05T03:01:22.004Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

